package com.Liux.blog.controller;


import com.Liux.blog.entity.Comments;
import com.Liux.blog.service.CommentsService;
import com.Liux.blog.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/comments")
public class CommentsController {

    @Autowired
    private CommentsService commentsService;

    @PostMapping("/add")
    public ResultVo add(Comments comments){
        return commentsService.addComment(comments);
    }
    @PostMapping("/update")
    public ResultVo update(Comments comments){
        return commentsService.updateComment(comments);
    }
    @DeleteMapping("/del")
    public ResultVo del(String cid){
        return commentsService.delComments(cid);
    }
    @GetMapping("/list")
    public ResultVo list(){
        return  commentsService.getComments();
    }
    @GetMapping("/detail")
    public ResultVo detail(String cid){
        return commentsService.getCommentsById(cid);
    }
}
